package com.ourteam.product.requirement.api;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.requirement.dao.IProductVersionStageDAO;
import com.ourteam.product.requirement.dao.ProductVersionStageDAOQueryBean;
import com.ourteam.product.requirement.domain.ProductVersionBean;

public class ProductVersionStageSearchModel extends AbstractSearchModel<ProductVersionStageDAOQueryBean> {

	private long productVersionId;

	public long getProductVersionId() {
		return productVersionId;
	}

	public void setProductVersionId(long productVersionId) {
		this.productVersionId = productVersionId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductVersionBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductVersionStageDAOQueryBean queryBean) throws Exception {

		ProductVersionStageDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (productVersionId != 0) {
			criteria.andProductVersionIdEqualTo(productVersionId);
		}

		if (queryBean.getSortProperties().isEmpty()) {
			queryBean.setSortProperty(IProductVersionStageDAO.StartDate);
		}

	}

}
